<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    table {
        border: solid;
    }

    td {
        border: solid 1px;
    }
</style>

<body>
    <table>
        <thead>
            <tr>
                <td>姓名</td>
                <td>成绩</td>
                <td>排名</td>
                <td>操作</td>
            </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
    <script>
        var tbody = document.querySelector('tbody');
        var basic = document.querySelector('.basic');

        var data = [{
                name: '小明',
                grade: '80',
                score: '4'
            },
            {
                name: 'Jonhn',
                grade: '90',
                score: '2'
            },
            {
                name: 'jack',
                grade: '88',
                score: '3'
            },
            {
                name: 'LIli',
                grade: '77',
                score: '6'
            }
        ];
        for (var i = 0; i < data.length; i++) {
            // var tmp = basic.cloneNode(true);
            // console.log(tmp);
            var tr = document.createElement('tr');
            tbody.appendChild(tr);
            for (k in data[i]) {
                var td = document.createElement('td');
                td.innerHTML = data[i][k];
                tr.appendChild(td);
            }
            var td = document.createElement('td');
            td.innerHTML = "<a href='javascript:;'>删除</a>"
            tr.appendChild(td);

        }
        var as = document.querySelectorAll('a');
        for (var i = 0; i < as.length; i++) {
            as[i].onclick = function () {
                tbody.removeChild(this.parentNode.parentNode);
            }
        }
        var trs = tbody.querySelectorAll("tr");
        for (var i = 0; i < trs.length; i++) {
            trs[i].onmouseover = function () {
                this.style.backgroundColor = "pink";
            }
            trs[i].onmouseout = function () {
                this.style.backgroundColor = "white";
            }
        }
    </script>
</body>

</html>